﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace libhtml
{
    public class Unit
    {
        // 标识
        public string tag;
        // 编码
        public string code;
        // 回调
        public string click;
        // 跳转方式
        public string gotoo;

        public void read(string[] strs)
        {
            code = strs[0];
            gotoo = strs[1];
            click = strs[2];
            tag = strs[3];
        }
    }

    // 建筑物
    public class Building : Unit
    {
        // 楼号
        public string tag2;
        // 单元组
        public Unit[] units;

        public void read(StreamReader reader)
        {
            string str = reader.ReadLine();
            string[] strs = str.Split(' ');
            read(strs);
            tag2 = strs[4];
            int size = int.Parse(strs[5]);
            units = new Unit[size];
            for (int k = 0; k < size; ++k)
            {
                str = reader.ReadLine();
                strs = str.Split(' ');
                units[k] = new Unit();
                units[k].read(strs);
            }
        }
    }

    public class Info : Unit
    {
        // 地址
        public string addr;
        // 门号
        // 操作id
        public string operid;
        // 建筑组
        public Building[] buildings;

        public void read(StreamReader reader)
        {
            string str = reader.ReadLine();
            string[] strs = str.Split(' ');
            read(strs);
            addr = strs[4];
            operid = strs[5];
            int size = int.Parse(strs[6]);
            buildings = new Building[size];
            for (int k = 0; k < size; ++k)
            {
                buildings[k] = new Building();
                buildings[k].read(reader);
            }
        }
    }
}
